<include file="public/layout" />
<body style="background-color: #FFF; overflow: auto;">
<div id="append_parent"></div>
<div id="ajaxwaitid"></div>
<div class="page">
    <div class="fixed-bar">
        <div class="item-title">
            <div class="subject">
                <h3>商城设置</h3>
                <h5>网站全局内容基本选项设置</h5>
            </div>
            <ul class="tab-base nc-row">
                <li><a href="{:U('System/index')}"><span>商城信息</span></a></li>
                <li><a href="{:U('System/index',array('inc_type'=>'basic'))}" ><span>基本设置</span></a></li>
                <li><a href="{:U('System/index',array('inc_type'=>'shopping'))}"><span>购物流程</span></a></li>
                <li><a href="{:U('System/index',array('inc_type'=>'sms'))}" ><span>短信设置</span></a></li>
                <li><a href="{:U('System/index',array('inc_type'=>'smtp'))}" ><span>邮件设置</span></a></li>
                <li><a href="{:U('System/index',array('inc_type'=>'water'))}" ><span>水印设置</span></a></li>
                <li><a href="{:U('System/index',array('inc_type'=>'distribut'))}" class="current"><span>分销设置</span></a></li>
                <!--<li><a href="{:U('System/index',array('inc_type'=>'wap'))}" ><span>WAP设置</span></a></li>-->
                <!--<li><a href="{:U('System/index',array('inc_type'=>'extend'))}" ><span>扩展设置</span></a></li>-->
            </ul>
        </div>
    </div>
    <!-- 操作说明 -->
    <div class="explanation" id="explanation">
        <div class="title" id="checkZoom"><i class="fa fa-lightbulb-o"></i>
            <h4 title="提示相关设置操作时应注意的要点">操作提示</h4>
            <span id="explanationZoom" title="收起提示"></span> </div>
        <ul>
            <li>系统平台全局设置,包括基础设置、购物、短信、邮件、水印和分销等相关模块。</li>
        </ul>
    </div>
    <form method="post" enctype="multipart/form-data" id="handlepost" action="{:U('System/handle')}">
        <input type="hidden" name="form_submit" value="ok" />
        <div class="ncap-form-default">
            <dl class="row">
                <dt class="tit">分销开关</dt>
                <dd class="opt">
                    <div class="onoff">
                        <label for="switch1" class="cb-enable  <if condition="$config['switch'] eq 1">selected</if>">开启</label>
                        <label for="switch0" class="cb-disable <if condition="$config['switch'] eq 0">selected</if>">关闭</label>
                        <input type="radio" id="switch1"  name="switch" value="1" <if condition="$config['switch'] eq 1">checked="checked"</if>>
                        <input type="radio" id="switch0" name="switch" value="0" <if condition="$config['switch'] eq 0">checked="checked"</if> >
                    </div>
                    <p class="notic">分销开关</p>
                </dd>
            </dl>
            <dl class="row">
                <dt class="tit">
                    <label>成为分销商条件</label>
                </dt>
                <dd class="opt">
                    <input type="radio" name="condition" value="0" <if condition="$config[condition] eq 0">checked="checked"</if>>直接成为分销商:  &nbsp;&nbsp;&nbsp;&nbsp;
                    <input type="radio" name="condition" value="1" <if condition="$config[condition] eq 1">checked="checked"</if>>成功购买商品后成为分销商:  &nbsp;&nbsp;&nbsp;&nbsp;
                    <p class="notic">分销商条件</p>
                </dd>
            </dl>
            <dl class="row">
                <dt class="tit">
                    <label>分销名称</label>
                </dt>
                <dd class="opt">
                    <input name="name" value="{$config.name}" class="input-txt" type="text">
                    <p class="notic">分销名称</p>
                </dd>
            </dl>
            <dl class="row">
                <dt class="tit">
                    <label for="distribut_date">分销模式</label>
                </dt>
                <dd class="opt">
                    <select name="pattern" id="distribut_pattern">
                        <option value="0" <if condition="$config['pattern'] eq 0">selected="selected"</if>>按商品设置的分成金额</option>
                        <option value="1" <if condition="$config['pattern'] eq 1">selected="selected"</if>>按订单设置的分成比例</option>
                    </select>
                    <p class="notic">分销模式</p>
                </dd>
            </dl>
            <dl class="row" <if condition="$config['pattern'] eq 0">style="display:none"</if>>
                <dt class="tit">
                    <label>订单默认分成比例</label>
                </dt>
                <dd class="opt">
                    <input name="order_rate" value="{$config.order_rate}" onpaste="this.value=this.value.replace(/[^\d]/g,'')" onkeyup="this.value=this.value.replace(/[^\d]/g,'')" class="input-txt" type="text">
                    <p class="notic">订单默认分成比例</p>
                </dd>
            </dl>
            <dl class="row">
                <dt class="tit">
                    <label>一级分销商名称</label>
                </dt>
                <dd class="opt">
                    <input name="first_name" value="{$config.first_name}" class="input-txt" type="text">
                    <p class="notic">一级分销商名称</p>
                </dd>
            </dl>
            <dl class="row">
                <dt class="tit">
                    <label>一级分销商比例</label>
                </dt>
                <dd class="opt">
                    <input name="first_rate" id="distribut_first_rate" value="{$config.first_rate}"onpaste="this.value=this.value.replace(/[^\d]/g,'')" onkeyup="this.value=this.value.replace(/[^\d]/g,'')" class="input-txt" type="text">
                    <p class="notic">单位：%</p>
                </dd>
            </dl>
            <dl class="row">
                <dt class="tit">
                    <label>二级分销商名称</label>
                </dt>
                <dd class="opt">
                    <input name="second_name" value="{$config.second_name}" class="input-txt" type="text">
                    <p class="notic">二级分销商名称</p>
                </dd>
            </dl>
            <dl class="row">
                <dt class="tit">
                    <label>二级分销商比例</label>
                </dt>
                <dd class="opt">
                    <input name="second_rate" id="distribut_second_rate" value="{$config.second_rate}"onpaste="this.value=this.value.replace(/[^\d]/g,'')" onkeyup="this.value=this.value.replace(/[^\d]/g,'')" class="input-txt" type="text">
                    <p class="notic">单位：%</p>
                </dd>
            </dl>
            <!--<dl class="row">
                <dt class="tit">
                    <label>三级分销商名称</label>
                </dt>
                <dd class="opt">
                    <input name="third_name" value="{$config.third_name}" class="input-txt" type="text">
                    <p class="notic">三级分销商名称</p>
                </dd>
            </dl>
            <dl class="row">
                <dt class="tit">
                    <label>三级分销商比例</label>
                </dt>
                <dd class="opt">
                    <input name="third_rate" id="distribut_third_rate" value="{$config.third_rate}"onpaste="this.value=this.value.replace(/[^\d]/g,'')" onkeyup="this.value=this.value.replace(/[^\d]/g,'')" class="input-txt" type="text">
                    <p class="notic">单位：%</p>
                </dd>
            </dl>-->
            <dl class="row">
                <dt class="tit">
                    <label for="distribut_date">分成时间</label>
                </dt>
                <dd class="opt">
                    <select name="date" id="distribut_date">
                        <for start="1" end="31" name="i" >
                            <option value="{$i}" <if condition="$config[date] eq $i">selected="selected"</if>>{$i}天</option>
                        </for>
                    </select>
                    <p class="notic">订单收货确认后多少天可以分成</p>
                </dd>
            </dl>
            <div class="bot">
                <input type="hidden" name="inc_type" value="{$inc_type}">
                <a href="JavaScript:void(0);" class="ncap-btn-big ncap-btn-green" onclick="adsubmit()">确认提交</a>
            </div>
        </div>
    </form>
</div>
<div id="goTop"> <a href="JavaScript:void(0);" id="btntop"><i class="fa fa-angle-up"></i></a><a href="JavaScript:void(0);" id="btnbottom"><i class="fa fa-angle-down"></i></a></div>
<script>
    $('#distribut_pattern').change(function(){
        if($(this).val() == 1)
            $('#distribut_order_rate').show();
        else
            $('#distribut_order_rate').hide();
    });

    function adsubmit(){
        var distribut_first_rate  = $.trim($('#distribut_first_rate').val());
        var distribut_second_rate = $.trim($('#distribut_second_rate').val());
        var distribut_third_rate  = $.trim($('#distribut_third_rate').val());

        var rate = parseInt(distribut_first_rate) + parseInt(distribut_second_rate) + parseInt(distribut_third_rate);
        if(rate > 100)
        {
            layer.msg('三个分销商比例总和不得超过100%', {icon: 2,time: 2000});//alert('少年，邮箱不能为空！');
            // alert('三个分销商比例总和不得超过100%');
            return false;
        }

        $('#handlepost').submit();
    }
</script>
</body>
</html>